<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Postalcode extends CI_Controller {

	public function get_province()
	{
		$this->load->model('postalcode_model');
		$data['postal_list'] = json_encode( $this->postalcode_model->get_province() );
		$this->load->view('display_postal', $data);
	}
	
	public function get_town($province_id = ''){
		$this->load->model('postalcode_model');
		$result = $this->postalcode_model->get_town($province_id);
		$data['postal_list'] = ($result) ? json_encode($result) : '';
		$this->load->view('display_postal', $data);
	}
	
	public function get_barangay($town_id = ''){
		$this->load->model('postalcode_model');
		$result = $this->postalcode_model->get_barangay($town_id);
		$data['postal_list'] = ($result) ? json_encode($result) : '';
		$this->load->view('display_postal', $data);
	}
	
	public function get_pcode($town_id = '', $barangay_id = ''){
		$this->load->model('postalcode_model');
		$result = $this->postalcode_model->get_pcode($town_id, $barangay_id);
		$data['postal_list'] = ($result) ? json_encode($result) : '';
		$this->load->view('display_postal', $data);
	}
	
}